package com.lirh.data.mongodbdemo.contorller;

import com.lirh.data.mongodbdemo.model.Comment;
import com.lirh.data.mongodbdemo.service.CommentService;
import com.lirh.data.mongodbdemo.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("comment")
public class CommentController {
    @Autowired
    private CommentService commentService;
//    查询所有
    @GetMapping("findAll")
    public R findAll(){
         return R.ok().put("data",commentService.findAll());
    }
//    新增
    @PostMapping("/save/{sid}")
    public R save(@RequestBody Comment comment,@PathVariable("sid")String sid){
        commentService.save(comment,sid);
        return R.ok("保存成功");

    }}
